/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Schnittstellen.Graphisches.Modelle;

import com.jme3.asset.AssetManager;
import com.jme3.asset.DesktopAssetManager;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Spatial;

/**
 *
 * @author Geez
 */
public class JmeModell extends Modell {

    private Vector3f scale;

    public JmeModell() {
        scale = new Vector3f(1, 1, 1);
    }

    public JmeModell(String name) {
        this();
        this.editorName = name;
    }

    public Vector3f getScale() {
        return scale;
    }

    public void setScale(Vector3f scale) {
        this.scale = scale;
    }

    public Spatial getModel(AssetManager assetmgr) {
        if (assetmgr == null) {
            throw new IllegalArgumentException("no assetmgr");
        }
        Spatial s = assetmgr.loadModel("Models/" + editorName.substring(0, editorName.length() - 4) + "/" + editorName);
        Material m = new Material(assetmgr, "Common/MatDefs/Misc/Unshaded.j3md");
        m.setColor("Color", ColorRGBA.Gray);
        s.setMaterial(m);
        s.setLocalTranslation(0, 0, 0);
        if (s != null) {
            s.setLocalScale(scale);
            return s;
        }

        return null;
    }
    
}
